package com.zscat.mallplus.center.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zscat.mallplus.center.BaseController;
import com.zscat.mallplus.center.entity.CenterH5;
import com.zscat.mallplus.center.service.ICenterH5Service;
import com.zscat.mallplus.utils.CommonResult;
import com.zscat.mallplus.utils.ValidatorUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/center/H5")
public class CenterH5Controller extends BaseController{

	@Resource
	private ICenterH5Service centerH5Service;
	
	@PostMapping("/update/{id}")
	public Object update(@RequestBody CenterH5 entity)
	{
		return toAjax(centerH5Service.updateById(entity));
	}
	
	@GetMapping("list")
	public Object list(CenterH5 entity) {
		return new CommonResult().success(centerH5Service.list(new QueryWrapper<>(entity)));
	}
	
    @GetMapping(value = "/{id}")
    public Object getCenterH5ById(@PathVariable Long id) {
        try {
            if (ValidatorUtils.empty(id)) {
                return new CommonResult().paramFailed("H5预约表id");
            }
            CenterH5 coupon = centerH5Service.getById(id);
            return new CommonResult().success(coupon);
        } catch (Exception e) {
            log.error("H5预约表明细：%s", e.getMessage(), e);
            return new CommonResult().failed();
        }

    }
}
